#include <memory>
#include <vector>

using namespace std;

#include "IMPAuto.hpp"
#include "dataquery/NIDataQueryHeaderAll.h"

#include <iostream>
#include <iomanip>
#include <string>

int main()
{
    Navinfo::IMPAuto::SDKControl* p_SDKControl = CreateIMPAutoSDK();
    p_SDKControl->Config("../config/config.ini");
    p_SDKControl->Start();

    Navinfo::IMPAuto::DataQuery::IDataQueryManager* p_DataQuery = GetDataQuery();

    std::shared_ptr<Navinfo::IMPAuto::DataQuery::IDataQueryAssist> assist = nullptr;
    if(p_DataQuery->CreateAssist(assist) == 0)
    {
        std::cout<<"Assist success"<<std::endl;
    }
    else
    {
        std::cout<<"Assist failed"<<std::endl;
    }

    std::vector<Navinfo::Nis::CLinkGeoId> id_list(0);
    auto loc = Navinfo::Nis::CCoord2D(
        Navinfo::IMPAuto::Util::CNICoordConv::Degree2NICoord(116.335624724),
        Navinfo::IMPAuto::Util::CNICoordConv::Degree2NICoord(40.011314957)
    );
    if(assist->SearchLinkGeoByRadiusRange(loc, 100, id_list) == 0)
    {
        std::cout<<"Search LinkGeo success: "<<id_list.size()<<std::endl;
        for(const auto& id: id_list)
        {
            std::cout<<"ID:\t"<<id.m_usLinkGeoId<<std::endl;
        }
    }
    else
    {
        std::cout<<"Search LinkGeo failed"<<std::endl;
    }
    
    p_SDKControl->Release();
    p_SDKControl = 0;

    return 0;
}
